fid = fopen('SectorCorporateBonds.txt','r');
LoadSectorIssuance;
all=out;
fid = fopen('SectorCorporateBondsESG.txt','r');
LoadSectorIssuance;
esg=out;
fid = fopen('SectorCorporateBondsGB.txt','r');
LoadSectorIssuance;
gb=out;
fid = fopen('CurrencyCorporateBonds.txt','r');
LoadSectorIssuance;
allc=out;
fid = fopen('CurrencyCorporateBondsESG.txt','r');
LoadSectorIssuance;
esgc=out;
fid = fopen('CurrencyCorporateBondsGB.txt','r');
LoadSectorIssuance;
gbc=out;
%1=Issue Date	2=Amount Issued (USD)	3=ESG Bond	4=Domicile	5=Green Bond	6=Amount Issued
fid = fopen('GovtBondsESG.txt','r');
form='%f %f %s %s %s %f';
in = textscan(fid, form,'delimiter','\t','HeaderLines',1);
fclose(fid);

N=length(in{1});
govt.country=unique(in{4});
govt.dat=zeros(N,5);
govt.header{1}='Issue Date';
govt.dat(:,1)=x2mdate(in{1});
govt.header{2}='Country';
[dummy govt.dat(:,2)]=ismember(in{4},govt.country);
govt.header{3}='Amount Issued (USD)';
govt.dat(:,3)=in{2};
govt.header{4}='ESG bond (1=yes,0=no)';
govt.dat(:,4)=ismember(in{3},'Yes');
govt.header{5}='Green bond (1=yes,0=no)';
govt.dat(:,5)=ismember(in{5},'Yes');

govt.years=min(year(govt.dat(:,1))):2023;
govt.datsum=zeros(length(govt.country),length(govt.years),3);
for c=1:length(govt.country)
    dat2=govt.dat(govt.dat(:,2)==c,:);
    for y=1:length(govt.years)
        dat3=dat2(year(dat2(:,1))==govt.years(y),:);
        if isempty(dat3)==0
            govt.datsum(c,y,1)=nansum(dat3(:,3)); %all bonds
            govt.datsum(c,y,2)=nansum(dat3(dat3(:,4)==1,3)); %esg bonds  
            govt.datsum(c,y,3)=nansum(dat3(dat3(:,5)==1,3)); %green bonds   
        else end
    end
end

ind=sum((govt.datsum(:,2:7,1))'==0)==0;
country=govt.country(ind);
